package leetcode.二叉树;

public class 左叶子之和404 {
    private static Integer ans = 0;
    public int sumOfLeftLeaves(TreeNode root) {
        ans = 0;
        process(root);
        return ans;
    }

    private void process(TreeNode root) {
        if(root == null)
            return;
        if(root.left != null && root.left.left == null && root.left.right == null){
            ans += root.left.val;
        }
        process(root.left);
        process(root.right);
    }
}
